package com.lfw.store1.aop;
//Aop不是Spring的特有的所以需要导包
    /*<dependency>
    <groupId>org.aspectj</groupId>
    <artifactId>aspectjweaver</artifactId>
    </dependency>
    <dependency>
    <groupId>org.aspectj</groupId>
    <artifactId>aspectjtools</artifactId>
    </dependency>*/


import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

@Component //将当前类的对象创建使用维护交由Spring容器维护
@Aspect // 将当前类标记为切面类
//使用环绕通知进行编写
public class TimerAspect {
    @Around("execution(* com.lfw.store1.service.impl.*.*(..))")

    public Object around(ProceedingJoinPoint pjp) throws Throwable {
        long start = System.currentTimeMillis();
        Object result = pjp.proceed(); //调用目标方法：login

        long end = System.currentTimeMillis();
        System.err.println("耗时：" + (end - start) + "ms.");
        return result;
    }
}
